import CircleWidget from "@/widgets/CircleWidget";
import PolygonWidget from "@/widgets/PolygonWidget"

const widgetTable = {
  CircleWidget,
  PolygonWidget
}

// 按名称获取图标组件对象
export const getWidgetByName = (name) => {
  return widgetTable[name];
}

// 按名称获取组件模板
export const getWidgetTemplateByName = (name) => {
  switch (name) {
    case 'CircleWidget': {
      return {
        dx: 0,
        dy: 0,
        props: {
          radius: 10
        }
      }
    };
    case 'PolygonWidget': {
      return {
        dx: 50,
        dy: 50,
        props: {
          width: 100,
          height: 100,
          pointIds: []
        },
        points: [
          {
            dx: 93,
            dy: 34,
          }, {
            dx: 93,
            dy: 79,
          }, {
            dx: 21,
            dy: 94,
          }, {
            dx: 6,
            dy: 5,
          }
        ]
      }
    }
  }
}